﻿using com.iot.core.annotation;
using com.iot.core.data;
using com.iot.core.util;
using com.iot.ht.Controllers.htsoft.service;
using com.iot.ht.Controllers.httask.service;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Linq;

namespace com.iot.ht.Controllers.httask.data
{
    [Schema(Name = "任务表Dto", Description = "")]     
    public class HtTaskAppStateDto : BaseDto
    {


        [Comment("名称")]
        [Schema(Name = "名称", Description = "")]
        [Required(ErrorMessage = "{0}不能为空")]
        [MaxLength(50)]
        public string Name { get; set; } = "";


        [Comment("是否启动")]
        [Schema(Name = "是否启动", Description = "")] 
        public bool Started { get; set; }

        

        [Comment("上次运行时间")]
        [Schema(Name = "上次运行时间", Description = "")]
        public DateTime LstDt { get; set; } 

        public string StrLstDt
        { get {
                if (!Started|| LstDt.Year<2023)
                {
                    return "";
                }
                return LstDt.ToString(DateUtil.DateFormatString);
            } 
        }  


        [Comment("上次运行结果")]
        [Schema(Name = "上次运行结果", Description = "")]
        public bool LstResult { get; set; }

        [Comment("上次运行信息")]
        [Schema(Name = "上次运行信息", Description = "")]
        public string LstMsg { get; set; }
         

        [NotMapped]
        [JsonIgnore]
        [Comment("配置")]
        [Schema(Name = "配置", Description = "")]
        public HtTaskApp HtTaskApp { get; set; }


        [NotMapped]
        [JsonIgnore]
        [Comment("需要启动")]
        [Schema(Name = "需要启动", Description = "")]

        public bool NeedStart { get; set; }



        [NotMapped]
        [JsonIgnore]
        [Comment("启动类")]
        [Schema(Name = "启动类", Description = "")]
        public HtAbstractTask HtAbstractTask { get; set; }

  
    }
}
